package gwtspeechbubble.client;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;

public class Arrow extends Composite {
    private boolean shadow;
    private FlowPanel base;

    public Arrow() {
        base = new FlowPanel();
        base.setWidth("16px");
        base.setHeight("8px");
        initWidget(base);
        DOM.setStyleAttribute(getElement(), "background", "url(images/arrow.gif)");
        positionBelow();
    }

    private void positionBelow() {
        DOM.setStyleAttribute(base.getElement(), "position", "relative");
        DOM.setStyleAttribute(base.getElement(), "top", "-2px");
        DOM.setStyleAttribute(base.getElement(), "left", "0px");
    }

    public void realignArrow(int offsetWidth) {
        if (shadow) {
            DOM.setStyleAttribute(base.getElement(), "left", ((offsetWidth / 2) - 20) + "px");
        } else {
            DOM.setStyleAttribute(base.getElement(), "left", ((offsetWidth / 2) - 7) + "px");
        }
    }
}
